package com.fit2cloud.common.provider.impl.vsphere;

import com.fit2cloud.common.platform.credential.Credential;
import com.fit2cloud.common.platform.credential.impl.VsphereCredential;
import com.fit2cloud.common.provider.AbstractBaseCloudProvider;
import com.fit2cloud.common.provider.entity.F2CBalance;
import com.fit2cloud.common.provider.impl.vsphere.api.VsphereBaseMethodApi;
import com.fit2cloud.common.provider.impl.vsphere.entity.request.GetRegionsRequest;
import com.fit2cloud.common.utils.JsonUtil;
import org.pf4j.Extension;

import java.util.List;
import java.util.Map;


@Extension
public class VsphereBaseCloudProvider extends AbstractBaseCloudProvider<VsphereCredential> {

    private static final String logoSvg = "<svg width=\"160\" height=\"38\" viewBox=\"0 0 160 38\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n" +
            "<g clip-path=\"url(#clip0_37_9492)\">\n" +
            "<path d=\"M37.9825 3.42847H29.3523L28.0723 4.70847H37.9825C39.0871 4.70972 40.1461 5.14906 40.9271 5.93011C41.7082 6.71116 42.1475 7.77013 42.1487 8.87471V29.9822C42.1475 31.0868 41.7082 32.1458 40.9271 32.9268C40.1461 33.7079 39.0871 34.1472 37.9825 34.1485H29.6159L28.3359 35.4285H37.9825C39.4264 35.4268 40.8107 34.8525 41.8318 33.8315C42.8528 32.8105 43.4271 31.4262 43.4287 29.9822V8.87471C43.4271 7.43078 42.8528 6.04647 41.8318 5.02546C40.8107 4.00445 39.4264 3.43012 37.9825 3.42847Z\" fill=\"#78BE20\"/>\n" +
            "<path d=\"M26.7837 34.1485H16.875C15.7704 34.1472 14.7114 33.7079 13.9304 32.9268C13.1493 32.1458 12.71 31.0868 12.7087 29.9822V8.87471C12.71 7.77013 13.1493 6.71116 13.9304 5.93011C14.7114 5.14906 15.7704 4.70972 16.875 4.70847H25.2402L26.5202 3.42847H16.875C15.431 3.43012 14.0467 4.00445 13.0257 5.02546C12.0047 6.04647 11.4304 7.43078 11.4287 8.87471L11.4287 29.9822C11.4304 31.4262 12.0047 32.8105 13.0257 33.8315C14.0467 34.8525 15.431 35.4268 16.875 35.4285H25.5037L26.7837 34.1485Z\" fill=\"#00C1D5\"/>\n" +
            "<path d=\"M37.0893 31.6399H23.2322C22.5653 31.6392 21.926 31.374 21.4545 30.9024C20.9829 30.4309 20.7177 29.7916 20.7169 29.1247V14.9222C20.7176 14.2554 20.9829 13.616 21.4544 13.1445C21.926 12.6729 22.5653 12.4077 23.2322 12.407H37.0893C37.7562 12.4077 38.3955 12.673 38.867 13.1445C39.3385 13.6161 39.6038 14.2554 39.6045 14.9222V29.1244C39.6038 29.7913 39.3386 30.4307 38.8671 30.9023C38.3956 31.3739 37.7562 31.6392 37.0893 31.6399ZM23.2322 13.687C22.9047 13.6873 22.5907 13.8176 22.3591 14.0492C22.1275 14.2808 21.9973 14.5947 21.9969 14.9222V29.1244C21.9973 29.4519 22.1276 29.7659 22.3591 29.9974C22.5907 30.229 22.9047 30.3592 23.2322 30.3596H37.0893C37.4167 30.3592 37.7307 30.2289 37.9622 29.9973C38.1937 29.7658 38.3239 29.4518 38.3243 29.1244V14.9222C38.3239 14.5948 38.1937 14.2808 37.9621 14.0492C37.7305 13.8176 37.4166 13.6873 37.0891 13.687H23.2322ZM19.4775 25.1278H17.691C17.3635 25.1274 17.0495 24.9971 16.8179 24.7655C16.5864 24.5339 16.4561 24.2199 16.4558 23.8924V9.69C16.4561 9.36252 16.5864 9.04855 16.818 8.81698C17.0495 8.58542 17.3635 8.45516 17.691 8.4548H31.5483C31.8757 8.45516 32.1897 8.58542 32.4213 8.81698C32.6528 9.04855 32.7831 9.36252 32.7835 9.69V11.1343H34.0635V9.69C34.0627 9.02317 33.7975 8.38386 33.3259 7.91233C32.8544 7.44081 32.2151 7.17557 31.5483 7.1748H17.691C17.0241 7.17557 16.3848 7.44081 15.9133 7.91233C15.4418 8.38386 15.1765 9.02317 15.1758 9.69V23.8924C15.1765 24.5593 15.4418 25.1986 15.9133 25.6701C16.3848 26.1417 17.0241 26.4069 17.691 26.4077H19.4775V25.1278Z\" fill=\"#0091DA\"/>\n" +
            "</g>\n" +
            "<g clip-path=\"url(#clip1_37_9492)\">\n" +
            "<path d=\"M92.3642 26.0774L88.113 14.1603C88.0433 14.0209 87.9736 13.8118 87.9736 13.6027C87.9736 13.1149 88.3918 12.5574 89.0887 12.5574C89.5765 12.5574 89.9947 12.9058 90.2037 13.4633L93.6883 23.7079L97.2425 13.3937C97.3819 12.9058 97.7304 12.4877 98.2879 12.4877H98.4273C98.9848 12.4877 99.403 12.8361 99.5423 13.3937L103.027 23.7079L106.581 13.3937C106.721 12.9755 106.999 12.5574 107.626 12.5574C108.254 12.5574 108.672 12.9755 108.672 13.533C108.672 13.7421 108.602 13.9512 108.532 14.0906L104.212 26.0077C104.003 26.6349 103.584 26.9834 103.027 26.9834H102.957C102.469 26.9834 101.982 26.7046 101.772 26.0077L98.2879 15.9025L94.8033 26.0077C94.5943 26.6349 94.2458 26.9834 93.6186 26.9834H93.5489C92.9914 27.0531 92.5732 26.6349 92.3642 26.0774Z\" fill=\"#717074\"/>\n" +
            "<path d=\"M123.447 13.6723C123.447 13.1148 123.865 12.5573 124.492 12.5573C125.05 12.5573 125.607 12.9754 125.607 13.6723V16.1115C126.652 13.742 128.952 12.6966 130.416 12.6966C131.043 12.6966 131.461 13.1148 131.461 13.8117C131.461 14.3692 131.113 14.7874 130.485 14.9267C127.767 15.2055 125.537 17.2962 125.537 21.3383V26.0773C125.537 26.6348 125.119 27.1924 124.492 27.1924C123.934 27.1924 123.377 26.7742 123.377 26.0773V13.6723\" fill=\"#717074\"/>\n" +
            "<path d=\"M138.22 27.1227C134.457 27.1227 131.391 24.1956 131.391 19.8748V19.8051C131.391 15.763 134.178 12.5573 138.011 12.5573C142.123 12.5573 144.423 15.9024 144.423 19.6657C144.423 20.2233 144.005 20.6414 143.447 20.6414H133.412C133.69 23.6381 135.851 25.3804 138.29 25.3804C139.963 25.3804 141.287 24.7532 142.262 23.7775C142.402 23.6381 142.611 23.5684 142.82 23.5684C143.308 23.5684 143.726 23.9866 143.726 24.4744C143.726 24.6835 143.656 24.9622 143.447 25.1016C142.123 26.2864 140.59 27.1227 138.22 27.1227ZM142.332 19.0385C142.123 16.4599 140.66 14.2995 137.942 14.2995C135.502 14.2995 133.69 16.3206 133.481 19.0385H142.332Z\" fill=\"#717074\"/>\n" +
            "<path d=\"M108.602 22.8018C108.602 19.8051 111.041 18.2022 114.595 18.2022C116.407 18.2022 117.661 18.4113 118.916 18.7597V18.2719C118.916 15.6933 117.383 14.5086 114.734 14.5086C113.341 14.5086 112.504 14.648 111.459 15.1358C111.32 15.2055 111.18 15.2055 111.11 15.2055C110.623 15.2055 110.135 14.7874 110.135 14.2995C110.135 13.8117 110.344 13.6026 110.692 13.3935C112.086 12.836 113.131 12.5573 114.943 12.5573C116.895 12.5573 118.428 13.0451 119.473 14.0905C120.449 15.0661 120.937 16.4599 120.937 18.2022V25.9379C120.937 26.4954 120.519 26.9833 119.891 26.9833C119.334 26.9833 118.846 26.5651 118.846 26.0076V24.6138C117.87 25.9379 116.198 27.053 113.759 27.053C111.25 27.1227 108.602 25.6592 108.602 22.8018ZM118.916 21.6868V20.2929C117.87 20.0142 116.477 19.7354 114.734 19.7354C112.086 19.7354 110.623 20.9202 110.623 22.6624V22.7321C110.623 24.4744 112.225 25.5198 114.107 25.5198C116.825 25.5198 118.916 23.9169 118.916 21.6868Z\" fill=\"#717074\"/>\n" +
            "<path d=\"M54.3127 13.4633C53.8946 12.4179 52.7099 11.9998 51.6645 12.4179C50.6191 12.8361 50.201 14.0905 50.7585 15.0662L55.2187 24.7532C55.9156 26.2864 56.6822 27.1227 58.0761 27.1227C59.5396 27.1227 60.1668 26.2167 60.9334 24.7532C60.9334 24.7532 64.8361 16.2509 64.9058 16.1812C64.9755 16.1115 65.0451 15.8328 65.4633 15.8328C65.8118 15.8328 66.0208 16.1115 66.0208 16.46V24.6835C66.0208 25.938 66.7177 27.053 68.0419 27.053C69.4357 27.053 70.1326 26.0077 70.1326 24.6835V17.9932C70.1326 16.6691 71.1083 15.8328 72.293 15.8328C73.5474 15.8328 74.3837 16.7388 74.3837 17.9932V24.7532C74.3837 26.0077 75.0806 27.1227 76.4048 27.1227C77.7986 27.1227 78.4955 26.0774 78.4955 24.7532V17.9932C78.4955 16.6691 79.4712 15.8328 80.6559 15.8328C81.9104 15.8328 82.7467 16.7388 82.7467 17.9932V24.7532C82.7467 26.0077 83.4436 27.1227 84.7677 27.1227C86.1615 27.1227 86.8584 26.0774 86.8584 24.7532V17.0872C86.8584 14.2299 84.6283 12.2785 81.8407 12.2785C79.053 12.2785 77.3804 14.1602 77.3804 14.1602C76.4048 12.9755 75.22 12.2785 73.0596 12.2785C70.8295 12.2785 68.8085 14.1602 68.8085 14.1602C67.9025 12.9755 66.2996 12.2785 65.1148 12.2785C63.1635 12.2785 61.5606 13.1845 60.5849 15.3449L57.7276 22.0353L54.3127 13.4633Z\" fill=\"#717074\"/>\n" +
            "<path d=\"M144.493 14.2995C144.493 13.3239 145.329 12.5573 146.235 12.5573C147.211 12.5573 147.978 13.3935 147.978 14.2995C147.978 15.2752 147.141 16.0418 146.235 16.0418C145.26 16.0418 144.493 15.2752 144.493 14.2995ZM147.629 14.2995C147.629 13.4632 147.072 12.9057 146.235 12.9057C145.399 12.9057 144.842 13.5329 144.842 14.2995C144.842 15.1358 145.399 15.6933 146.235 15.6933C147.072 15.6933 147.629 15.0661 147.629 14.2995Z\" fill=\"#717074\"/>\n" +
            "<path d=\"M146.932 14.3695C146.862 14.4392 146.722 14.5089 146.583 14.5785L147.001 15.2058H146.653L146.235 14.5785H145.956V15.2058H145.607V13.3938H146.374C146.513 13.3938 146.583 13.3938 146.722 13.4635C146.792 13.5332 146.932 13.6029 146.932 13.6726C147.001 13.7423 147.001 13.8816 147.001 13.9513C147.071 14.1604 147.001 14.2998 146.932 14.3695ZM145.956 14.2998H146.374C146.513 14.2998 146.583 14.2998 146.653 14.2301C146.722 14.1604 146.722 14.0907 146.722 14.021C146.722 13.9513 146.653 13.8816 146.653 13.8119C146.583 13.7423 146.513 13.7423 146.374 13.7423H145.956V14.2998Z\" fill=\"#717074\"/>\n" +
            "</g>\n" +
            "<defs>\n" +
            "<clipPath id=\"clip0_37_9492\">\n" +
            "<rect width=\"33\" height=\"33\" fill=\"white\" transform=\"translate(11 3)\"/>\n" +
            "</clipPath>\n" +
            "<clipPath id=\"clip1_37_9492\">\n" +
            "<rect width=\"98.2857\" height=\"14.8571\" fill=\"white\" transform=\"translate(50.2861 11.9999)\"/>\n" +
            "</clipPath>\n" +
            "</defs>\n" +
            "</svg>\n";

    private static final String iconSvg = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 400 400\"><path d=\"M331.922,0H224.044l-16,16H331.922A52.137,52.137,0,0,1,384,68.078V331.922A52.137,52.137,0,0,1,331.922,384H227.339l-16,16H331.922A68.156,68.156,0,0,0,400,331.922V68.078A68.156,68.156,0,0,0,331.922,0Z\" fill=\"#78be20\"/><path d=\"M191.937,384H68.078A52.137,52.137,0,0,1,16,331.922V68.078A52.137,52.137,0,0,1,68.078,16H172.643l16-16H68.078A68.156,68.156,0,0,0,0,68.078V331.922A68.156,68.156,0,0,0,68.078,400H175.937Z\" fill=\"#00c1d5\"/><path d=\"M320.763,352.644H147.549a31.476,31.476,0,0,1-31.441-31.44V143.673a31.476,31.476,0,0,1,31.441-31.441H320.763a31.476,31.476,0,0,1,31.44,31.441V321.2A31.476,31.476,0,0,1,320.763,352.644ZM147.549,128.232a15.459,15.459,0,0,0-15.441,15.441V321.2a15.458,15.458,0,0,0,15.441,15.44H320.763A15.457,15.457,0,0,0,336.2,321.2V143.673a15.458,15.458,0,0,0-15.44-15.441Zm-46.933,143.01H78.284A15.458,15.458,0,0,1,62.844,255.8V78.27a15.457,15.457,0,0,1,15.44-15.44H251.5a15.457,15.457,0,0,1,15.44,15.44V96.324h16V78.27A31.476,31.476,0,0,0,251.5,46.83H78.284a31.476,31.476,0,0,0-31.44,31.44V255.8a31.476,31.476,0,0,0,31.44,31.441h22.332Z\" fill=\"#0091da\"/></svg>";

    private static final CloudAccountMeta cloudAccountMeta = new CloudAccountMeta(VsphereCredential.class, "fit2cloud_vsphere_platform", "VMware", false,
            logoSvg, iconSvg, Map.of());

    private static final Info info = new Info("management-center", List.of(), Map.of());

    public List<Credential.Region> getRegions(String req) {
        return VsphereBaseMethodApi.getRegions(JsonUtil.parseObject(req, GetRegionsRequest.class));
    }

    @Override
    public F2CBalance getAccountBalance(String getAccountBalanceRequest) {
        return null;
    }

    @Override
    public CloudAccountMeta getCloudAccountMeta() {
        return cloudAccountMeta;

    }

    @Override
    public Info getInfo() {
        return info;
    }


}
